package com.ffdms.mobileoffice;

import java.util.Date;

import com.ffdms.util.MobileOfficeUtil;
import com.ffdms.vo.PlanInfo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class PlanActivity extends Activity {
	private TextView tv_title;
	private Button btn_return;
	private Button btn_popup;
	private TextView tv_plan_title_content;
	private TextView tv_plan_type_content;
	private TextView tv_plan_time_content;
	private TextView tv_plan_version_content;
	private TextView tv_plan_detail_item_content1;
	private TextView tv_plan_detail_item_content2;
	private TextView tv_plan_summary1;
	private TextView tv_plan_base_section_title;
	private TextView tv_plan_content_section_title;
	private TextView tv_plan_summary_section_title;
	private RelativeLayout rl_plan_base_section;
	private RelativeLayout rl_plan_content_section;
	private RelativeLayout rl_plan_summary_section;
	private int type;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_plan);

		tv_title = (TextView) findViewById(R.id.tv_title);
		tv_title.setText("");

		btn_return = (Button) findViewById(R.id.btn_return);
		btn_return.setVisibility(View.VISIBLE);
		btn_return.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				finish();
			}
		});

		type = getIntent().getIntExtra("type", 0);
		switch (type) {
		case 0:
			btn_return.setText("周计划");
			break;
		case 1:
			btn_return.setText("月计划");
			break;
		case 2:
			btn_return.setText("年计划");
			break;
		case 3:
			btn_return.setText("自定义计划");
			break;
		case 4:
			btn_return.setText("评阅计划");
			break;
		default:
			break;
		}
		btn_popup = (Button) findViewById(R.id.btn_popup);
		btn_popup.setText("编辑");
		btn_popup.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent t = new Intent(PlanActivity.this, PlanEditActivity.class);
				t.putExtra("type", type);
				startActivity(t);
				finish();
			}
		});

		// get plan info from db
		PlanInfo p = new PlanInfo();
		p.setName("2013年第22周计划");
		p.setAddTime(MobileOfficeUtil.formatDate("yyyy-MM-dd HH:mm:ss", new Date()));
		p.setEnterpriseID(1);
		p.setModifyTime(MobileOfficeUtil.formatDate("yyyy-MM-dd HH:mm:ss", new Date()));
		p.setDescription("本报讯 （记者徐海星、张涨 通讯员郑仁鹏、黄少江、陈建族）同饮珠江水，保护母亲河。昨天下午2时，2013年广州横渡珠江活动在中大码头举行。来自广州、佛山、肇庆、清远、东莞、中山等6市的2000名横渡健儿组成了40个方队依次下水，在热烈的加油欢呼声中游抵位于二沙岛星海音乐厅附近的登陆点。广州市委书记万庆良、市长陈建华，市领导陈国、王世彤、欧阳卫民、平欣光，市政府秘书长周亚伟;佛山市市长刘悦伦，市领导林征、赖紫宁，以及肇庆、清远、东莞、中山等市有关游泳协会负责人分别率领各市方队成功横渡。");
		p.setPlanTypeID(1);

		tv_plan_title_content = (TextView) findViewById(R.id.tv_plan_title_content);
		tv_plan_title_content.setText(p.getName());
		tv_plan_type_content = (TextView) findViewById(R.id.tv_plan_type_content);
		tv_plan_type_content.setText("周计划");
		tv_plan_time_content = (TextView) findViewById(R.id.tv_plan_time_content);
		tv_plan_time_content.setText(p.getModifyTime());
		tv_plan_version_content = (TextView) findViewById(R.id.tv_plan_version_content);
		tv_plan_version_content.setText("0");
		tv_plan_detail_item_content1 = (TextView) findViewById(R.id.tv_plan_detail_item_content1);
		tv_plan_detail_item_content1.setText(p.getDescription());
		tv_plan_detail_item_content2 = (TextView) findViewById(R.id.tv_plan_detail_item_content2);
		tv_plan_detail_item_content2.setText(p.getDescription());
		tv_plan_summary1 = (TextView) findViewById(R.id.tv_plan_summary1);
		tv_plan_summary1.setText(p.getDescription());

		tv_plan_base_section_title = (TextView) findViewById(R.id.tv_plan_base_section_title);
		rl_plan_base_section = (RelativeLayout) findViewById(R.id.rl_plan_base_section);
		tv_plan_base_section_title.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (rl_plan_base_section.getVisibility() == View.GONE) {
					rl_plan_base_section.setVisibility(View.VISIBLE);
				} else {
					rl_plan_base_section.setVisibility(View.GONE);
				}
			}
		});
		tv_plan_content_section_title = (TextView) findViewById(R.id.tv_plan_content_section_title);
		rl_plan_content_section = (RelativeLayout) findViewById(R.id.rl_plan_content_section);
		rl_plan_content_section.setVisibility(View.GONE);
		tv_plan_content_section_title.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (rl_plan_content_section.getVisibility() == View.GONE) {
					rl_plan_content_section.setVisibility(View.VISIBLE);
					rl_plan_summary_section.setVisibility(View.GONE);
				} else {
					rl_plan_content_section.setVisibility(View.GONE);
				}
			}
		});
		tv_plan_summary_section_title = (TextView) findViewById(R.id.tv_plan_summary_section_title);
		rl_plan_summary_section = (RelativeLayout) findViewById(R.id.rl_plan_summary_section);
		rl_plan_summary_section.setVisibility(View.GONE);
		tv_plan_summary_section_title.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (rl_plan_summary_section.getVisibility() == View.GONE) {
					rl_plan_summary_section.setVisibility(View.VISIBLE);
					rl_plan_content_section.setVisibility(View.GONE);
				} else {
					rl_plan_summary_section.setVisibility(View.GONE);
				}
			}
		});
	}
}
